<!DOCTYPE html>
<HTML>

<head>
    <title>修改密码</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link href="static/css/default.css?v=20191209" rel="stylesheet">
</head>

<body>

    <form class="form-horizontal layui-form" lay-filter="pwdFormFilter" action="javascript:;">
        <div class="box-body">
            <div class="form-group">
                <label class="col-sm-3 control-label">密码</label>
                <div class="col-sm-9">
                    <input class="form-control" name="UserPwd" type="password" required lay-verify="required|pass"
                        autofocus="autofocus" placeholder>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">确认密码</label>
                <div class="col-sm-9">
                    <input class="form-control" name="UserPwd2" type="password" required lay-verify="required:pass"
                        placeholder>
                </div>
            </div>
        </div>
        <div class="box-footer">
            <button class="btn btn-primary pull-right w-25" type="submit" lay-submit
                lay-filter="pwdBtnFilter">保存</button>
        </div>
    </form>

    <script src="static/js/jquery-3.3.1.min.js"></script>
    <script src="static/Plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="static/Plugins/layui/layui.all.js"></script>
    <script src="static/js/jquery-confirm.min.js"></script>
    <script src="static/js/jquery-ext-user.js?v=20191209"></script>

    <script>
        $(function () {
            form.on('submit(pwdBtnFilter)', function (data) {
                if (data.field.UserPwd != data.field.UserPwd2) {
                    win.msg('两次输入的密码不相等');
                } else {
                    $.postdata('/clientApi/UserMain/UpdateMyPwd',
                        data.field,
                        function (res) {
                            if (res) {
                                win.msg('密码修改成功');

                                // 重置
                                form.val("pwdFormFilter", {
                                    UserPwd: '',
                                    UserPwd2: '',
                                });
                            } else {
                                win.alert("修改失败")
                            }
                        });
                }

                return false;
            });

        });
    </script>
</body>

</HTML>